package com.imooc.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

/**
 * @author 逸尘风清
 * @date 2021/5/11
 * @time 11:21
 * 描述：
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Resource
    private FileConfig fileConfig;

    //实现静态资源的映射
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**")
                .addResourceLocations("classpath:/META-INF/resources/")//映射swagger2，否则会导致404
                .addResourceLocations("file:"+fileConfig.getImageUserFaceLocation());//这个就是映射的路径，下面的文件就可以通过localhost:8088/**/**/xxx.png来访问了
    }
}
